#!/usr/bin/python3
"""
(c) Copyright 2024, Denis Rozhnovskiy <pytelemonbot@mail.ru>
pyTeleMonBot - A simple Telegram bot designed to gather basic information about
the status of your local computers and/or servers from Glances
"""
from app import (
    __version__,
    __repository__,
    build_logger,
    bot
)
import app.core.handlers
import app.core.exceptions as exceptions


def init_app():
    log = build_logger(__name__)
    try:
        log.info('Starting bot...')
        log.info(f"New instance started! pyTeleMonBot v.{__version__} ({__repository__})")
        bot.infinity_polling()
    except ConnectionError as _error:
        log.critical('Error connecting to Telegram API')
        bot.stop_polling()
        raise exceptions.PyTeleMonBotConnectionError('Error connecting to Telegram') from _error


if __name__ == "__main__":
    init_app()
